import {useLocation} from 'react-router-dom';
import routes from '../routes';

export const useCurrentModule = () => {
    const {pathname} = useLocation();

    const currentModule = routes.find(route => {
        console.log(pathname);
        if (route.path === pathname) {
            return true;
        } else if (route.children) {
            return route.children.some(child => child.path === pathname);
        }
        return false;
    });
    console.log(currentModule);
    return currentModule;
};
